package cays.student.dao;

import cays.student.vo.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 学生信息的增删查改
 *
 * @author Chai yansheng
 * @create 2019/8/29
 **/
public interface StudentDao {
    @Select("select * from student")
    List<Student> getAllStudent();

    @Select("select * from student where sno = #{sno}")
    Student getStudentBySno(@Param("sno") String sno);

    @Update("<script>update student<set>" +
            "<if test='sname != null'>sname=#{sname},</if>" +
            "<if test='ssex != null'>ssex=#{ssex},</if>" +
            "<if test='sage != null'>sage=#{sage},</if>" +
            "<if test='sdep != null'>sdep=#{sdep},</if>" +
            "<if test='screate != null'>screate=#{screate}</if></set>" +
            "<where>sno=#{sno}</where>" +
            "</script>")
    int updateStudentBySno(Student student);

    @Insert("insert into student values (#{sno},#{sname},#{ssex},#{sage},#{sdep},#{screate})")
    int insertStudent(Student student);

    @Delete("delete student where sno=#{sno}")
    int deleteStudent(@Param("sno") String sno);

}
